﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;                 
using System.Data.SqlClient;

using System.Text;   


namespace finalexam
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "欢迎来到学生信息管理系统";

        }

        protected void btnRead_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112134;uid=2014112134;pwd=19951124";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();

                string strNo = this.txtNo.Text;
                string strCno = this.txtCno.Text;
                string strTime = this.txtTime.Text;

                string strSql = "SELECT Grade3.No,student.Name,Cource.Cname,Grade3.Grade FROM Grade3 INNER JOIN student ON Grade3.No = student.No INNER JOIN Cource ON Grade3.Cno = Cource.Cno WHERE(Grade3.Sem = N'"+strTime+"') AND (Grade3.Cno = N'"+ strCno +"') AND (Grade3.No = N'"+strNo+"')";

                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                this.GridView1.DataSource = dr;
                this.GridView1.DataBind();
                dr.Close();

               
            }
            catch (Exception ex)
            {
                this.Label5.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void btnRead1_Click(object sender, EventArgs e)
        {
            Response.Redirect("Grade2.aspx");
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["Theme"] = this.DropDownList1.SelectedValue.ToString();
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] != null)
                this.Theme = Session["Theme"].ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }

        

        

        
        

        
    }
}